import request from '@/utils/request'

// 查询列表
export function list(baseurl, query) {
  return request({
    url: `${baseurl}/list`,
    method: 'get',
    params: query,
  })
}

// 查询列表
export function recycle(baseurl, query) {
  return request({
    url: `${baseurl}/recycle`,
    method: 'get',
    params: query,
  })
}

// 查询总数
export function count(baseurl, query) {
  return request({
    url: `${baseurl}/count`,
    method: 'get',
    params: query,
  })
}

// 查询字典选择
export function dict(baseurl, query) {
  return request({
    url: `${baseurl}/dict`,
    method: 'get',
    params: query,
    headers: {
      isToken: false
    }
  })
}

// 查询详细信息
export function keys(baseurl, query) {
  return request({
    url: baseurl + '/keys',
    method: 'get',
    params: query,
  })
}
export function getOne(baseurl, id, query) {
  return request({
    url: `${baseurl}/${id ? id : 'one'}` ,
    method: 'get',
    params: query,
  })
}

// 查询详细信息
export function checkExist(baseurl, query) {
  return request({
    url: baseurl + '/exists',
    method: 'get',
    params: query,
  })
}

// 新增信息
export function save(baseurl, data) {
  return request({
    url: baseurl,
    method: 'post',
    data: data
  })
}

// 修改信息
export function update(baseurl, data) {
  return request({
    url: baseurl,
    method: 'put',
    data: data
  })
}

// 删除
export function remove(baseurl, id) {
  return request({
    url: `${baseurl}/${id}`,
    method: 'delete'
  })
}

// 彻底删除
export function clear(baseurl, id) {
  return request({
    url: `${baseurl}/remove/${id}`,
    method: 'delete'
  })
}

// 清空回收站
export function clean(baseurl) {
  return request({
    url: `${baseurl}/clean`,
    method: 'delete'
  })
}

// 撤销删除
export function restore(baseurl, id) {
  return request({
    url: `${baseurl}/restore/${id}`,
    method: 'post',
  })
}

export function clearCache(baseurl) {
  return request({
    url: `${baseurl}/clear`,
    method: 'delete'
  })
}
